package com.lc.app.androidfirst.userdefine.activity;

import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Gravity;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.lc.app.androidfirst.R;

public class ShowColorActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_show_color);
        LinearLayout layout = (LinearLayout) findViewById(R.id.testShowColor);

        int[] colorId = new int[]{R.color.color1,R.color.color2,R.color.color3,R.color.color4,R.color.color5,R.color.color6,R.color.color7};
        for (int i=0;i<colorId.length;i++){
            TextView textView = new TextView(this);

            textView.setBackgroundColor(getResources().getColor(colorId[i]));
            textView.setGravity(Gravity.CENTER);
            textView.setHeight((int) (getResources().getDimension(R.dimen.basic) * (i + 2) / 2));
            layout.addView(textView);
        }
    }

}
